import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout/Layout.vue'
Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Home.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/auth/Login.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/auth/Register.vue')
  },
  {
    path: '/bindaccount',
    name: 'BindAccount',
    meta: { title: '绑定账户' },
    component: () => import('../views/auth/BindAccount.vue')
  },
  {
    path: '/callback',
    name: 'Callback',
    component: () => import('../views/auth/_Callback.vue')
  },
  {
    path: '/user',
    meta: { title: '用户', needLogin: true },
    component: Layout,
    children: [
      { path: 'home', name: 'UserHome', meta: { title: '用户中心' }, component: () => import('../views/user/Home.vue') },
      { path: 'profile', name: 'UserProfile', meta: { title: '个人信息' }, component: () => import('../views/user/Profile.vue') },
      { path: 'evaluate', name: 'UserEvaluate', meta: { title: '评价管理' }, component: () => import('../views/user/Profile.vue') }
    ]
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes,
  scrollBehavior (to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    return { x: 0, y: 0 }
  }
})
export default router
